/*
*Copyright 2021-2023 NERCIS
*
*Licensed under the Apache License, Version 2.0 (the "License");
*you may not use this file except in compliance with the License.
*You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*Unless required by applicable law or agreed to in writing, software
*distributed under the License is distributed on an "AS IS" BASIS,
*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*See the License for the specific language governing permissions and
*limitations under the License.
*/

package cn.ac.nercis.pes.common.constant.evaluation;

import org.apache.commons.lang3.StringUtils;

/**
 * 测评项
 *
 * @author zpy
 * @version 1.0.0
 */
public enum EvaluationItem {
    /**未测评**/
    DEFAULT(0, ""),
    /**D**/
    D(1, "D"),
    /**A**/
    A(2, "A"),
    /**K**/
    K(3, "K"),
    /**结果记录**/
    MANAGE(5, "结果记录");
    private final Integer value;
    private final String name;

    EvaluationItem(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public static EvaluationItem fromValue(Integer value) {
        EvaluationItem data = DEFAULT;
        for (EvaluationItem tt : EvaluationItem.values()) {
            if (tt.getValue() == value) {
                data = tt;
                break;
            }
        }
        return data;
    }

    public static EvaluationItem fromName(String name) {
        EvaluationItem data = DEFAULT;
        for (EvaluationItem tt : EvaluationItem.values()) {
            if (StringUtils.equals(tt.getName(), name)) {
                data = tt;
                break;
            }
        }
        return data;
    }


    public int getValue() {
        return this.value;
    }

    public String getName() {
        return this.name;
    }
}